<template>
<van-cell
  class="article-item"
  :to="`/article/${article.art_id}`"
>
  <div class="article-title van-multi-ellipsis--l2" slot="title">
    {{article.title}}
  </div>
  <div slot="label">
    <div v-if="article.cover.type === 3" class="three-img">
      <div
        class="th-img"
        v-for="(item, index) in article.cover.images"
        :key="index"
      >
        <van-image
        class="img"
        :src="item"
        />
      </div>
    </div>
    <div class="article-desc" v-if="showDesc">
      <span class="au-desc">{{article.aut_name}}</span>
      <span class="au-desc">{{article.comm_count}}评论</span>
      <span class="au-desc">{{article.pubdate | relativeTime}}</span>
    </div>
  </div>
  <van-image
    v-if="article.cover.type === 1"
    class="one-img"
    slot="default"
    fit="cover"
    :src="article.cover.images[0]"
  />
</van-cell>
</template>

<script>
export default {
  name: 'ArticleItem',
  props: {
    article: {
      type: Object,
      required: true
    },
    showDesc: {
      type: Boolean,
      default: true,
      required: false
    }
  },
  data () {
    return {
    }
  }
}
</script>

<style scoped lang="less">
  .article-item {
    .article-title {
      font-size: 32px;
      font-weight: 600;
      color: #3a3a3a;
    }
    .van-cell__title {
      width: 100%;
    }
    .van-cell__value {
        flex: unset;
        width: 232px;
        height: 146px;
        padding-left: 25px;
      }
    .one-img {
      width: 232px;
      height: 146px;
    }
    .article-desc {
      margin-top: 30px;
      .au-desc {
        font-size: 23px;
        color: #b4b4b4;
        margin-right: 23px;
      }
    }
    .three-img {
      display: flex;
      .th-img {
        flex: 1;
        height: 146px;
        .img {
          width: 100%;
          height: 100%;
        }
      }
    }
  }
</style>
